<!--
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author ThinkGem
-->
<template>
  <div>
    <BasicTable @register="registerTable" @row-click="handleTestDataChildRowClick">
      <!-- 表格标题 -->
      <template #tableTitle>
        <Icon :icon="getTitle.icon" class="m-1 pr-1" />
        <span> {{ getTitle.value }} </span>
      </template>
      <!-- 表格右上角自定义按钮（新增...） -->
      <template #toolbar> </template>
      <template #firstColumn="{ record }"> </template>
    </BasicTable>
  </div>
</template>
<script lang="ts">
  export default defineComponent({
    name: 'ViewsCurrentStockDataList',
  });
</script>
<script lang="ts" setup>
  import { defineComponent } from 'vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { router } from '/@/router';
  import { Icon } from '/@/components/Icon';
  import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
  import { stockListData } from '/@/api/shop/order/soRds';
  import { FormProps } from '/@/components/Form';

  const { t } = useI18n('test.testData');
  const { showMessage } = useMessage();
  const getTitle = {
    icon: router.currentRoute.value.meta.icon || 'ant-design:book-outlined',
    value: router.currentRoute.value.meta.title || t('现存量查询'),
  };
  //配置表单内容
  const searchForm: FormProps = {
    baseColProps: { lg: 6, md: 8 },
    labelWidth: 90,
    schemas: [
      {
        label: '存货编码',
        field: 'cinvcode',
        component: 'Input',
      },
      {
        label: '存货名称',
        field: 'cinvname',
        component: 'Input',
      },
      {
        label: '仓库名称',
        field: 'cwhnamme',
        component: 'Input',
      },
    ],
  };
  //配置表格表头菜单
  const tableColumns: BasicColumn[] = [
    {
      title: '仓库编码',
      dataIndex: 'cwhcode',
      key: 'a.cwhcode',
      sorter: true,
      width: 60,
      align: 'center',
    },
    {
      title: '仓库名称',
      dataIndex: 'cwhname',
      key: 'a.cwhname',
      sorter: true,
      width: 60,
      align: 'center',
    },
    {
      title: '存货编码',
      dataIndex: 'cinvcode',
      key: 'a.cinvcode',
      sorter: true,
      width: 100,
      align: 'left',
    },
    {
      title: '存货名称',
      dataIndex: 'cinvname',
      key: 'a.cinvname',
      sorter: true,
      width: 150,
      align: 'left',
    },
    {
      title: '可用量',
      dataIndex: 'icanuseqty',
      key: 'a.icanuseqty',
      sorter: true,
      width: 80,
      align: 'right',
    },
    // {
    //   title: '分仓占用',
    //   dataIndex: 'dpredate',
    //   key: 'a.dpredate',
    //   sorter: false,
    //   width: 80,
    //   align: 'right',
    // },
  ];
  //配置表格右边操作按钮
  const actionColumn: BasicColumn = {
    width: 180,
    actions: (record: Recordable) => [],
  };

  const [registerTable, { reload }] = useTable({
    api: stockListData,
    beforeFetch: (params) => {
      return params;
    },
    columns: tableColumns, //配置表格内容数组对象
    //actionColumn: actionColumn, //配置表格右边操作按钮
    formConfig: searchForm, //配置表单内容
    showTableSetting: true, //表格右上角3个默认按钮
    useSearchForm: true, //表单是否展示
    canResize: true, //表格是否flex布局
    showIndexColumn: false,
  });

  function handleSuccess() {
    reload();
  }
</script>
